<?php

namespace App\Services\Applet\Other;

use Exception;

class AreaService extends BaseOtherService
{

    /**
     * 省市区列表
     * @param array $params
     * @return array
     * @throws Exception
     */
    public function list(array $params): array
    {
        $id = $params['id'] ?? 0;

        // 查询
        $areaList = $this->getAreaModel()->list($id, [
            'id', 'name', 'code'
        ]);

        $list = [];
        foreach ($areaList as $item) {
            $list[] = [
                'id' => intval($item['code']),
                'name' => $item['name'],
            ];
        }

        return [
            'list' => $list
        ];
    }

}
